var mongoose = require('mongoose')
    , Schema = mongoose.Schema;

var db = require('../index').db;

function getTime() {
    var date = new Date();
    return date.toLocaleString() + '.' + date.getMilliseconds();
}

var urlLogSchema = new Schema({
    time: {
        type: String,
        default: getTime
    },
    ip: String,
    referer: String,
    url: String,
    method: String,
    pid: String,
    host: String
}, {
        capped: {
            size: 300 * 1024 * 1024, // 最大300M
            max: 500000 // 最多50万条数据
        },
        versionKey: false, // 不自动插入__v字段
        collection: 'urlLog'
    });

// var urlLog = exports.urlLog = db.model('urlLog', urlLogSchema);
exports.urlLogSchema = urlLogSchema;